<?php
class QdttsvsController extends AppController {

	var $name = 'Qdttsvs';

	function index() {
		$this->Qdttsv->recursive = 0;
		$this->set('qdttsvs', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid qdttsv', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('qdttsv', $this->Qdttsv->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Qdttsv->create();
			if ($this->Qdttsv->save($this->data)) {
				$this->Session->setFlash(__('The qdttsv has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The qdttsv could not be saved. Please, try again.', true));
			}
		}
		$ttdoansvs = $this->Qdttsv->Ttdoansv->find('list');
		$sinhviens = $this->Qdttsv->Sinhvien->find('list');
		$this->set(compact('ttdoansvs', 'sinhviens'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid qdttsv', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->Qdttsv->save($this->data)) {
				$this->Session->setFlash(__('The qdttsv has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The qdttsv could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Qdttsv->read(null, $id);
		}
		$ttdoansvs = $this->Qdttsv->Ttdoansv->find('list');
		$sinhviens = $this->Qdttsv->Sinhvien->find('list');
		$this->set(compact('ttdoansvs', 'sinhviens'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for qdttsv', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Qdttsv->delete($id)) {
			$this->Session->setFlash(__('Qdttsv deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Qdttsv was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
}
?>